package com.aaa.mapper;

import org.apache.ibatis.annotations.*;

import com.aaa.entity.Users;

/**
 * 持久层可以简单理解为数据的 "仓库管理员"，存储，取出，修改，删除
 * 持久层是数据访问层
 * **/
@Mapper
public interface UserMapper {

    //用户登录
    @Select("select * from users where phone_number=#{phone} and password=#{password}")
    public Users loginUser(String phone, String password);

    //判断手机号是否存在
    @Select("select * from users where phone_number =#{phoneNumber}")
    public Users findByPhoneName(String phoneNumber);

    //根据用户id修改登录密码
    @Update("update users set password = #{password} where id=#{id}")
    @Options(useGeneratedKeys = false)
    public int updatePassword(String id, String password);
    
    //根据用户ID查询用户信息
    @Select("select * from users where id = #{id}")
    public Users findById(String id);

}